package com.example.module_main.view

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.module_main.R
import com.example.module_main.adapter.ServiceAdapter
import com.example.module_main.entity.ServiceEntityItem


class ServiceFragment : Fragment() {
    lateinit var serviceAdapter: ServiceAdapter
    lateinit var list: List<ServiceEntityItem>
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        // Inflate the layout for this fragment
        val view: View = inflater.inflate(R.layout.fragment_service, container, false)
        val serviceRv:RecyclerView  = view.findViewById<RecyclerView>(R.id.service_rv)
        list = listOf(
            ServiceEntityItem(R.drawable.ic_car1,"车辆管理"),
            ServiceEntityItem(R.drawable.ic_car_park,"车位管理"),
            ServiceEntityItem(R.drawable.ic_visitor,"访客管理"),
            ServiceEntityItem(R.drawable.ic_maintenance,"维修管理"),
            ServiceEntityItem(R.drawable.img_1,"公告管理"),
            ServiceEntityItem(R.drawable.img_2,"考勤管理"),
            ServiceEntityItem(R.drawable.img_3,"即时通讯"),
            ServiceEntityItem(R.drawable.img_4,"设备管理"),
            ServiceEntityItem(R.drawable.img_5,"房源信息"),
            ServiceEntityItem(R.drawable.img_6,"物业保修"),
            ServiceEntityItem(R.drawable.img_7,"巡检管理"),
            ServiceEntityItem(R.drawable.img_8,"月卡会员")
        )
        serviceAdapter = ServiceAdapter()
        serviceRv.adapter=serviceAdapter
        serviceRv.layoutManager=GridLayoutManager(requireContext(),3)
        serviceAdapter.data.addAll(list)
        serviceAdapter.notifyDataSetChanged()
        return view
    }


}